home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 051-075 / 055 / vt100 / init.c < prev    next >
C/C++ Source or Header  |  1995-03-13  |  19KB  |  591 lines

  1. /***************************************************************
  2.  * vt100 - terminal emulator - initialization
  3.  *
  4.  *    v2.6 870227 DBW - bug fixes for all the stuff in v2.5
  5.  *    v2.5 870214 DBW - more additions (see readme file)
  6.  *    v2.4 861214 DBW - lots of fixes/additions (see readme file)
  7.  *    v2.3 861101 DBW - minor bug fixes
  8.  *    v2.2 861012 DBW - more of the same
  9.  *    v2.1 860915 DBW - new features (see README)
  10.  *         860901 ACS    - Added Parity and Word Length and support code
  11.  *         860823 DBW - Integrated and rewrote lots of code
  12.  *    v2.0 860809 DBW - Major rewrite
  13.  *    v1.1 860720 DBW    - Switches, 80 cols, colors, bug fixes
  14.  *    v1.0 860712 DBW    - First version released
  15.  *
  16.  ***************************************************************/
  17.  
  18. #include "vt100.h"
  19.  
  20. char line[256];
  21. static char cmds[] = "V^GRSBLHXEOIT.DWKCZ";
  22.  
  23. char *InitDefaults(argc,argv)
  24. int    argc;
  25. char    **argv;
  26.     {
  27.     FILE    *fd;
  28.     char    *p;
  29.     int        l;
  30.  
  31.     doing_init = 1;    /* make sure we only allow INIT script commands */
  32.     if (((argc > 1) && (fd=fopen(argv[1],"r")) != 0) ||
  33.     (fd=fopen("vt100.init","r")) != 0 ||
  34.     (fd=fopen("s:vt100.init","r")) != 0) {
  35.     while (fgets(line,256,fd) != 0) {
  36.         line[strlen(line)-1] = '\000';
  37.         p = next_wrd(&line[0],&l);
  38.         if (*p) {
  39.         *p |= ' ';
  40.         if (p[1]) p[1] |= ' ';
  41.         if (*p == '#') continue;
  42.         if (*p == 'e' && p[1] == 'x') break;
  43.         exe_cmd(p,l);
  44.         }
  45.         }
  46.     fclose(fd);
  47.     }
  48.     doing_init = 0;
  49.  
  50.     /* Now set up all the screen info as necessary */
  51.     if (p_interlace == 0) {
  52.     if (p_lines > 24) p_lines = 24;
  53.     MINY = 14;
  54.     NewWindow.Height    = (long)((p_lines*8)+8);
  55.     }
  56.     else {
  57.     if (p_lines > 48) p_lines = 48;
  58.     MINY = 16;
  59.     NewScreen.ViewModes |= LACE;
  60.     NewWindow.Height    = (long)((p_lines*8)+10);
  61.     }
  62.     NewWindow.MinHeight = NewWindow.Height;
  63.     NewWindow.MaxHeight = NewWindow.Height;
  64.     NewWindow.TopEdge   = 0L;
  65.     MAXY = ((p_lines-1)*8) + MINY;
  66.     top  = MINY;
  67.     bot     = MAXY;
  68.     savx = MINX;
  69.     savy = MINY;
  70.     if (p_screen == 1) {
  71.     if (p_depth > 2) p_depth = 2;
  72.     if (p_depth < 1) p_depth = 1;
  73.     NewScreen.Depth        = (long)p_depth;
  74.     NewScreen.Height    = (long)((p_lines*8)+16);
  75.     if (p_interlace == 1)
  76.         NewScreen.TopEdge   = (long)(400 - NewScreen.Height);
  77.     else
  78.         NewScreen.TopEdge   = (long)(208 - NewScreen.Height);
  79.     }
  80.     else {
  81.     p_depth            = 2L;
  82.     NewWindow.TopEdge    = 0L;
  83.     NewWindow.Screen    = NULL;
  84.     NewWindow.Type        = WBENCHSCREEN;
  85.     }
  86.     /* see if we exit with a startup script */
  87.     if (*p == 'e') {
  88.     p = next_wrd(p+l+1,&l);
  89.     if (*p) return(p);
  90.     }
  91.     return(NULL);
  92.     }
  93.  
  94. void InitDevs()
  95. {
  96. USHORT    colors[4];
  97. int    i;
  98. BYTE    *b,*c;
  99.  
  100. IntuitionBase = (struct IntuitionBase *)
  101.     OpenLibrary("intuition.library", INTUITION_REV);
  102. if( IntuitionBase == NULL )
  103.     cleanup("can't open intuition",1);
  104.  
  105. GfxBase = (struct GfxBase *)
  106.     OpenLibrary("graphics.library",GRAPHICS_REV);
  107. if( GfxBase == NULL )
  108.     cleanup("can't open graphics library",2);
  109.  
  110. if (p_screen == 1) {
  111.     if ((myscreen = (struct Screen *)OpenScreen(&NewScreen)) == NULL)
  112.     cleanup("can't open screen",3);
  113.     NewWindow.Screen = myscreen;
  114.     }
  115.  
  116. if ((mywindow = (struct Window *)OpenWindow(&NewWindow)) == NULL)
  117.     cleanup("can't open window",4);
  118. if ((myfont = (struct TextFont *)OpenFont(&myattr)) == NULL)
  119.     cleanup("can't open font",4);
  120.  
  121. myviewport   = (struct ViewPort *)ViewPortAddress(mywindow);
  122. myrastport   = (struct RastPort *)mywindow->RPort;
  123.  
  124. SetFont(myrastport,myfont);
  125.  
  126. if (p_depth > 1) myrequest.BackFill = 2;
  127. if (p_screen != 0 && p_wbcolors == 0) {
  128.     colors[0] = p_background;
  129.     colors[1] = p_foreground;
  130.     colors[2] = p_bold;
  131.     colors[3] = p_cursor;
  132.     if (p_depth == 1)
  133.     LoadRGB4(myviewport,(struct ColorMap *)colors,2L);
  134.     else
  135.         LoadRGB4(myviewport,(struct ColorMap *)colors,4L);
  136.     }
  137.  
  138. Read_Request = (struct IOExtSer *)
  139.     AllocMem((long)sizeof(*Read_Request),MEMF_PUBLIC|MEMF_CLEAR);
  140. Read_Request->io_SerFlags = 0L;
  141. Read_Request->IOSer.io_Message.mn_ReplyPort = CreatePort(0L,0L);
  142. if(OpenDevice(SERIALNAME,NULL,Read_Request,NULL))
  143.     cleanup("Cant open Read device",5);
  144. rs_in = malloc(p_buffer+1);
  145. Read_Request->io_SerFlags = 0L;
  146. Read_Request->io_Baud      = p_baud;
  147. Read_Request->io_ReadLen  = 8L;
  148. Read_Request->io_WriteLen = 8L;
  149. Read_Request->io_CtlChar  = 0x11130000L;
  150. Read_Request->io_RBufLen  = p_buffer;
  151. Read_Request->io_BrkTime  = p_break;
  152. Read_Request->IOSer.io_Command = SDCMD_SETPARAMS;
  153. DoIO(Read_Request);
  154. Read_Request->IOSer.io_Command = CMD_READ;
  155. Read_Request->IOSer.io_Length  = 1;
  156. Read_Request->IOSer.io_Data    = (APTR) &rs_in[0];
  157.  
  158. Write_Request = (struct IOExtSer *)
  159.     AllocMem((long)sizeof(*Write_Request),MEMF_PUBLIC|MEMF_CLEAR);
  160. b = (BYTE *)Read_Request;
  161. c = (BYTE *)Write_Request;
  162. for (i=0;i<sizeof(struct IOExtSer);i++) *c++ = *b++;
  163. Write_Request->IOSer.io_Message.mn_ReplyPort = CreatePort(0L,0L);
  164. Write_Request->IOSer.io_Command = CMD_WRITE;
  165. Write_Request->IOSer.io_Length  = 1;
  166. Write_Request->IOSer.io_Data    = (APTR) &rs_out[0];
  167.  
  168. Timer_Port = CreatePort("Timer Port",0L);
  169. Script_Timer_Port = CreatePort("Timer Port",0L);
  170.  
  171. if (OpenDevice(TIMERNAME, UNIT_VBLANK, (char *) &Timer, 0) ||
  172.     OpenDevice(TIMERNAME, UNIT_VBLANK, (char *) &Script_Timer, 0)) 
  173.     cleanup("can't open timer device",7);
  174.  
  175. Timer.tr_node.io_Message.mn_ReplyPort = Timer_Port;
  176. Timer.tr_node.io_Command = TR_ADDREQUEST;
  177. Timer.tr_node.io_Flags = 0;
  178. Timer.tr_node.io_Error = 0;
  179.  
  180. Script_Timer.tr_node.io_Message.mn_ReplyPort = Script_Timer_Port;
  181. Script_Timer.tr_node.io_Command = TR_ADDREQUEST;
  182. Script_Timer.tr_node.io_Flags = 0;
  183. Script_Timer.tr_node.io_Error = 0;
  184.  
  185. BeepWave   = (UBYTE *)AllocMem(BEEPSIZE,(long)(MEMF_CHIP|MEMF_CLEAR));
  186. if (BeepWave != 0) BeepWave[0] = 100;
  187.  
  188. Audio_Port = CreatePort("Audio Port",0L);
  189.  
  190. Audio_Request.ioa_Request.io_Message.mn_ReplyPort   = Audio_Port;
  191. Audio_Request.ioa_Request.io_Message.mn_Node.ln_Pri = 85;
  192. Audio_Request.ioa_Data            = Audio_AllocMap;
  193. Audio_Request.ioa_Length        = (ULONG) sizeof(Audio_AllocMap);
  194.  
  195. if (OpenDevice(AUDIONAME, NULL, (char *) &Audio_Request, NULL))
  196.     cleanup("can't open audio device",8);
  197.  
  198. Audio_Request.ioa_Request.io_Command    = CMD_WRITE;
  199. Audio_Request.ioa_Request.io_Flags    = ADIOF_PERVOL;
  200. Audio_Request.ioa_Data        = BeepWave;
  201. Audio_Request.ioa_Length    = BEEPSIZE;
  202. Audio_Request.ioa_Period    = COLORCLOCK / (BEEPSIZE * BEEPFREQ);
  203. Audio_Request.ioa_Volume    = p_volume;
  204. Audio_Request.ioa_Cycles    = 100;
  205. }
  206.  
  207. /*****************************************************************/
  208. /*    The following function initializes the structure arrays    */
  209. /*   needed to provide the File menu topic.                      */
  210. /*****************************************************************/
  211. void InitFileItems()
  212.     {
  213.     int        n,nplus1;
  214.  
  215. /* initialize each menu item and IntuiText with loop */
  216. for( n=0; n<FILEMAX; n++ )
  217.     {
  218.     nplus1 = n + 1;
  219.     FileItem[n].NextItem = &FileItem[nplus1];
  220.     FileItem[n].LeftEdge = 0;
  221.     FileItem[n].TopEdge = 10 * n;
  222.     FileItem[n].Width = 120+40;
  223.     FileItem[n].Height = 10;
  224.     FileItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP;
  225.     FileItem[n].MutualExclude = 0;
  226.     FileItem[n].ItemFill = (APTR)&FileText[n];
  227.     FileItem[n].SelectFill = NULL;
  228.     if (n >= 2 && n <= 7) {
  229.     FileItem[n].Command  = cmds[n-2];
  230.     FileItem[n].Flags   |= COMMSEQ;
  231.     }
  232.     else FileItem[n].Command = 0;
  233.     FileItem[n].SubItem = NULL;
  234.     FileItem[n].NextSelect = 0;
  235.  
  236.     FileText[n].FrontPen = 0;
  237.     FileText[n].BackPen = 1;
  238.     FileText[n].DrawMode = JAM2;/* render in fore and background */
  239.     FileText[n].LeftEdge = 0;
  240.     FileText[n].TopEdge = 1;
  241.     FileText[n].ITextFont = NULL;
  242.     FileText[n].NextText = NULL;
  243.     }
  244. FileItem[FILEMAX-1].NextItem = NULL;
  245.  
  246. /* initialize text for specific menu items */
  247.  
  248. FileText[0].IText = (UBYTE *)"Ascii  Capture";
  249. FileText[1].IText = (UBYTE *)"Ascii  Send";
  250. FileText[2].IText = (UBYTE *)"Xmodem Receive";
  251. FileText[3].IText = (UBYTE *)"Xmodem Send";
  252. FileText[4].IText = (UBYTE *)"Kermit Get";
  253. FileText[5].IText = (UBYTE *)"Kermit Receive";
  254. FileText[6].IText = (UBYTE *)"Kermit Send";
  255. FileText[7].IText = (UBYTE *)"Kermit BYE";
  256. }
  257.  
  258. /******************************************************************
  259. /*            Main Comm menu
  260. /*        set up for Baud & Parity submenus
  261. /******************************************************************/
  262. void InitCommItems()
  263.     {
  264.     int        n,nplus1;
  265.  
  266. /* initialize each menu item and IntuiText with loop */
  267. for( n=0; n<COMMAX; n++ )
  268.     {
  269.     nplus1 = n + 1;
  270.     CommItem[n].NextItem = &CommItem[nplus1];
  271.     CommItem[n].LeftEdge = 0;
  272.     CommItem[n].TopEdge = 10 * n;
  273.     CommItem[n].Width = 88;
  274.     CommItem[n].Height = 10;
  275.     CommItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP ;
  276.     CommItem[n].MutualExclude = 0;
  277.     CommItem[n].ItemFill = (APTR)&CommText[n];
  278.     CommItem[n].SelectFill = NULL;
  279.     CommItem[n].Command = 0;
  280.     CommItem[n].NextSelect = 0;
  281.  
  282.     CommText[n].FrontPen = 0;
  283.     CommText[n].BackPen = 1;
  284.     CommText[n].DrawMode = JAM2;    
  285.     CommText[n].LeftEdge = 0;
  286.     CommText[n].TopEdge = 1;
  287.     CommText[n].ITextFont = NULL;
  288.     CommText[n].NextText = NULL;
  289.     }
  290. CommItem[COMMAX-1].NextItem = NULL;
  291.  
  292. CommText[0].IText = (UBYTE *)"Baud Rate";
  293. CommText[1].IText = (UBYTE *)"Parity   ";
  294. CommText[2].IText = (UBYTE *)"Xfer Mode";
  295. CommItem[0].SubItem = RSItem;
  296. CommItem[1].SubItem = ParItem;
  297. CommItem[2].SubItem = XFItem;
  298.  
  299. /*****************************************************************/
  300. /*    The following initializes the structure arrays         */
  301. /*   needed to provide the BaudRate Submenu topic.               */
  302. /*****************************************************************/
  303.  
  304. for( n=0; n<RSMAX; n++ )
  305.     {
  306.     nplus1 = n + 1;
  307.     RSItem[n].NextItem = &RSItem[nplus1];
  308.     RSItem[n].LeftEdge = 75;
  309.     RSItem[n].TopEdge = 10 * n;
  310.     RSItem[n].Width = 56+40;
  311.     RSItem[n].Height = 10;
  312.     RSItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
  313.     RSItem[n].MutualExclude = (~(1 << n));
  314.     RSItem[n].ItemFill = (APTR)&RSText[n];
  315.     RSItem[n].SelectFill = NULL;
  316.     if (n >= 1 && n <= 2) {
  317.     RSItem[n].Command    = cmds[n+5];
  318.     RSItem[n].Flags        |= COMMSEQ;
  319.     }
  320.     else RSItem[n].Command = 0;
  321.     RSItem[n].SubItem = NULL;
  322.     RSItem[n].NextSelect = 0;
  323.  
  324.     RSText[n].FrontPen = 0;
  325.     RSText[n].BackPen = 1;
  326.     RSText[n].DrawMode = JAM2;     /* render in fore and background */
  327.     RSText[n].LeftEdge = 0;
  328.     RSText[n].TopEdge = 1;
  329.     RSText[n].ITextFont = NULL;
  330.     RSText[n].NextText = NULL;
  331.     }
  332. RSItem[RSMAX-1].NextItem = NULL;
  333.  
  334. /* select baud item chekced */
  335. switch (p_baud) {
  336.     case 300:    n = 0; break;
  337.     case 1200:    n = 1; break;
  338.     case 2400:    n = 2; break;
  339.     case 4800:    n = 3; break;
  340.     case 9600:    n = 4; break;
  341.     default:    n = 2; p_baud = 2400;
  342.     }
  343. RSItem[n].Flags |= CHECKED;
  344.  
  345. /* initialize text for specific menu items */
  346. RSText[0].IText = (UBYTE *)"   300";
  347. RSText[1].IText = (UBYTE *)"  1200";
  348. RSText[2].IText = (UBYTE *)"  2400";
  349. RSText[3].IText = (UBYTE *)"  4800";
  350. RSText[4].IText = (UBYTE *)"  9600";
  351.  
  352. /*****************************************************************/
  353. /*    The following initializes the structure arrays         */
  354. /*   needed to provide the Parity   Submenu topic.               */
  355. /*****************************************************************/
  356.  
  357. for( n=0; n<PARMAX; n++ )
  358.     {
  359.     nplus1 = n + 1;
  360.     ParItem[n].NextItem = &ParItem[nplus1];
  361.     ParItem[n].LeftEdge = 75;
  362.     ParItem[n].TopEdge = 10 * n;
  363.     ParItem[n].Width = 56+40;
  364.     ParItem[n].Height = 10;
  365.     ParItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
  366.     ParItem[n].MutualExclude = (~(1 << n));
  367.     ParItem[n].ItemFill = (APTR)&ParText[n];
  368.     ParItem[n].SelectFill = NULL;
  369.     if (n == 0 || n == 3 || n == 4) {
  370.     ParItem[n].Command   = cmds[(n==0)?8:n+6];
  371.     ParItem[n].Flags    |= COMMSEQ;
  372.     }
  373.     else ParItem[n].Command = 0;
  374.     ParItem[n].SubItem = NULL;
  375.     ParItem[n].NextSelect = 0;
  376.  
  377.     ParText[n].FrontPen = 0;
  378.     ParText[n].BackPen = 1;
  379.     ParText[n].DrawMode = JAM2;/* render in fore and background */
  380.     ParText[n].LeftEdge = 0;
  381.     ParText[n].TopEdge = 1;
  382.     ParText[n].ITextFont = NULL;
  383.     ParText[n].NextText = NULL;
  384.     }
  385. ParItem[PARMAX-1].NextItem = NULL;
  386.  
  387. /* select parity item chekced */
  388. ParItem[p_parity].Flags |= CHECKED;
  389.  
  390. /* initialize text for specific menu items */
  391. ParText[0].IText = (UBYTE *)"  None ";
  392. ParText[1].IText = (UBYTE *)"  Mark ";
  393. ParText[2].IText = (UBYTE *)"  Space";
  394. ParText[3].IText = (UBYTE *)"  Even ";
  395. ParText[4].IText = (UBYTE *)"  Odd  ";
  396.  
  397. /*****************************************************************/
  398. /*    The following initializes the structure arrays         */
  399. /*    needed to provide the Transfer Mode menu topic.            */
  400. /*****************************************************************/
  401.  
  402. /* initialize each menu item and IntuiText with loop */
  403. for( n=0; n<XFMAX; n++ )
  404.     {
  405.     nplus1 = n + 1;
  406.     XFItem[n].NextItem = &XFItem[nplus1];
  407.     XFItem[n].LeftEdge = 75;
  408.     XFItem[n].TopEdge = 10 * n;
  409.     XFItem[n].Width = 80+40;
  410.     XFItem[n].Height = 10;
  411.     XFItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
  412.     if (n < 2)  XFItem[n].MutualExclude = 2 - n;
  413.     else    XFItem[n].MutualExclude = 0;
  414.     XFItem[n].ItemFill = (APTR)&XFText[n];
  415.     XFItem[n].SelectFill = NULL;
  416.     if (n < 2) {
  417.     XFItem[n].Command    = cmds[n+11];
  418.     XFItem[n].Flags        |= COMMSEQ;
  419.     }
  420.     else XFItem[n].Command = 0;
  421.     XFItem[n].SubItem = NULL;
  422.     XFItem[n].NextSelect = 0;
  423.  
  424.     XFText[n].FrontPen = 0;
  425.     XFText[n].BackPen = 1;
  426.     XFText[n].DrawMode = JAM2;
  427.     XFText[n].LeftEdge = 0;
  428.     XFText[n].TopEdge = 1;
  429.     XFText[n].ITextFont = NULL;
  430.     XFText[n].NextText = NULL;
  431.     }
  432. XFItem[XFMAX-1].NextItem = NULL;
  433. /* mode checked */
  434. XFItem[p_mode].Flags |= CHECKED;
  435. if (p_convert)    XFItem[2].Flags |= CHECKED;
  436.  
  437. /* initialize text for specific menu items */
  438. XFText[0].IText = (UBYTE *)"  Image  ";
  439. XFText[1].IText = (UBYTE *)"  Text   ";
  440. XFText[2].IText = (UBYTE *)"  Convert";
  441.  
  442. } /* end of InitCommItems() */
  443.  
  444.  
  445. /*****************************************************************/
  446. /*    The following function initializes the structure arrays    */
  447. /*   needed to provide the Script menu topic.                    */
  448. /*****************************************************************/
  449. void InitScriptItems()
  450. {
  451. int n,nplus1;
  452.  
  453. /* initialize each menu item and IntuiText with loop */
  454. for( n=0; n<SCRIPTMAX; n++ )
  455.     {
  456.     nplus1 = n + 1;
  457.     ScriptItem[n].NextItem = &ScriptItem[nplus1];
  458.     ScriptItem[n].LeftEdge = 0;
  459.     ScriptItem[n].TopEdge = 10 * n;
  460.     ScriptItem[n].Width = 128;
  461.     ScriptItem[n].Height = 10;
  462.     ScriptItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP;
  463.     ScriptItem[n].MutualExclude = 0;
  464.     ScriptItem[n].ItemFill = (APTR)&ScriptText[n];
  465.     ScriptItem[n].SelectFill = NULL;
  466.     ScriptItem[n].Command = 0;
  467.     ScriptItem[n].SubItem = NULL;
  468.     ScriptItem[n].NextSelect = 0;
  469.  
  470.     ScriptText[n].FrontPen = 0;
  471.     ScriptText[n].BackPen = 1;
  472.     ScriptText[n].DrawMode = JAM2;/* render in fore and background */
  473.     ScriptText[n].LeftEdge = 0;
  474.     ScriptText[n].TopEdge = 1;
  475.     ScriptText[n].ITextFont = NULL;
  476.     ScriptText[n].NextText = NULL;
  477.     }
  478. ScriptItem[SCRIPTMAX-1].NextItem = NULL;
  479.  
  480. /* initialize text for specific menu items */
  481. ScriptText[0].IText = (UBYTE *)"Execute file";
  482. ScriptText[1].IText = (UBYTE *)"Abort Execution";
  483. }
  484.  
  485. /*****************************************************************/
  486. /*    The following function initializes the structure arrays    */
  487. /*   needed to provide the Util menu topic.                    */
  488. /*****************************************************************/
  489. void InitUtilItems()
  490.     {
  491.     int        n,nplus1;
  492.  
  493. /* initialize each menu item and IntuiText with loop */
  494. for( n=0; n<UTILMAX; n++ )
  495.     {
  496.     nplus1 = n + 1;
  497.     UtilItem[n].NextItem = &UtilItem[nplus1];
  498.     UtilItem[n].LeftEdge = 0;
  499.     UtilItem[n].TopEdge = 10 * n;
  500.     UtilItem[n].Width = 88+40;
  501.     UtilItem[n].Height = 10;
  502.     UtilItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP;
  503.     if (n > 3) UtilItem[n].Flags |= CHECKIT;
  504.     UtilItem[n].MutualExclude = 0;
  505.     UtilItem[n].ItemFill = (APTR)&UtilText[n];
  506.     UtilItem[n].SelectFill = NULL;
  507.     if (n == 0 || n == 2) {
  508.     UtilItem[n].Command   = cmds[(n==0)?13:14];
  509.     UtilItem[n].Flags    |= COMMSEQ;
  510.     }
  511.     else if (n >= 5) {
  512.     UtilItem[n].Command   = cmds[n+10];
  513.     UtilItem[n].Flags    |= COMMSEQ;
  514.     }
  515.     else UtilItem[n].Command = 0;
  516.     UtilItem[n].SubItem = NULL;
  517.     UtilItem[n].NextSelect = 0;
  518.  
  519.     UtilText[n].FrontPen = 0;
  520.     UtilText[n].BackPen = 1;
  521.     UtilText[n].DrawMode = JAM2;/* render in fore and background */
  522.     UtilText[n].LeftEdge = 0;
  523.     UtilText[n].TopEdge = 1;
  524.     UtilText[n].ITextFont = NULL;
  525.     UtilText[n].NextText = NULL;
  526.     }
  527. UtilItem[UTILMAX-1].NextItem = NULL;
  528.  
  529. if (p_echo)        UtilItem[4].Flags |= CHECKED;
  530. if (p_wrap)        UtilItem[5].Flags |= CHECKED;
  531. if (p_keyapp == 0)  UtilItem[6].Flags |= CHECKED;
  532. if (p_curapp)        UtilItem[7].Flags |= CHECKED;
  533. if (p_bs_del)        UtilItem[8].Flags |= CHECKED;
  534.  
  535. /* initialize text for specific menu items */
  536. UtilText[0].IText = (UBYTE *)"Send Break";
  537. UtilText[1].IText = (UBYTE *)"Hang Up";
  538. UtilText[2].IText = (UBYTE *)"Change Dir";
  539. UtilText[3].IText = (UBYTE *)"Clear Scrn";
  540. UtilText[4].IText = (UBYTE *)"  Echo";
  541. UtilText[5].IText = (UBYTE *)"  Wrap";
  542. UtilText[6].IText = (UBYTE *)"  Num Key";
  543. UtilText[7].IText = (UBYTE *)"  App Cur";
  544. UtilText[8].IText = (UBYTE *)"  BS<->DEL";
  545. }
  546.  
  547. /****************************************************************/
  548. /*   The following function inits the Menu structure array with */
  549. /*  appropriate values for our simple menu.  Review the manual  */
  550. /*  if you need to know what each value means.                  */
  551. /****************************************************************/
  552. void InitMenu()
  553. {
  554. menu[0].NextMenu = &menu[1];
  555. menu[0].LeftEdge = 5;
  556. menu[0].TopEdge = 0;
  557. menu[0].Width = 40;
  558. menu[0].Height = 10;
  559. menu[0].Flags = MENUENABLED;
  560. menu[0].MenuName = "File";        /* text for menu-bar display */
  561. menu[0].FirstItem = &FileItem[0]; /* pointer to first item in list */
  562.  
  563. menu[1].NextMenu = &menu[2];
  564. menu[1].LeftEdge = 55;
  565. menu[1].TopEdge = 0;
  566. menu[1].Width = 88;
  567. menu[1].Height = 10;
  568. menu[1].Flags = MENUENABLED;
  569. menu[1].MenuName = "Comm Setup";   /* text for menu-bar display */
  570. menu[1].FirstItem = &CommItem[0];  /* pointer to first item in list */
  571.  
  572. menu[2].NextMenu = &menu[3];
  573. menu[2].LeftEdge = 153;
  574. menu[2].TopEdge = 0;
  575. menu[2].Width = 56;
  576. menu[2].Height = 10;
  577. menu[2].Flags = MENUENABLED;
  578. menu[2].MenuName = "Script";        /* text for menu-bar display */
  579. menu[2].FirstItem = &ScriptItem[0]; /* pointer to first item in list*/
  580.  
  581. menu[3].NextMenu = NULL;
  582. menu[3].LeftEdge = 225;
  583. menu[3].TopEdge = 0;
  584. menu[3].Width = 64;
  585. menu[3].Height = 10;
  586. menu[3].Flags = MENUENABLED;
  587. menu[3].MenuName = "Utility";      /* text for menu-bar display */
  588. menu[3].FirstItem = &UtilItem[0];  /* pointer to first item in list*/
  589. }
  590.  
  591.